package com.mall.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.business.domain.TAwardProduct;
import com.mall.business.service.ITAwardProductService;
import com.mall.common.core.page.TableDataInfo;

/**
 * 抽奖设置Controller
 *
 * @author ruoyi
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/business/awardproduct" )
public class TAwardProductController extends BaseController {
    @Autowired
    private ITAwardProductService tAwardProductService;

/**
 * 查询抽奖设置列表
 */
//@RequiresPermissions("business:awardproduct:list")
@GetMapping("/list" )
    public TableDataInfo list(TAwardProduct tAwardProduct) {
        startPage();
        List<TAwardProduct> list = tAwardProductService.selectTAwardProductList(tAwardProduct);
        return getDataTable(list);
    }

    /**
     * 导出抽奖设置列表
     */
    //@RequiresPermissions("business:awardproduct:export")
    @Log(title = "抽奖设置" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, TAwardProduct tAwardProduct) {
        List<TAwardProduct> list = tAwardProductService.selectTAwardProductList(tAwardProduct);
        ExcelUtil<TAwardProduct> util = new ExcelUtil<TAwardProduct>(TAwardProduct. class);
        util.exportExcel(response, list, "抽奖设置数据" );
    }

    /**
     * 获取抽奖设置详细信息
     */
    //@RequiresPermissions("business:awardproduct:query")
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(tAwardProductService.getById(id));
    }

    /**
     * 新增抽奖设置
     */
    //@RequiresPermissions("business:awardproduct:add")
    @Log(title = "抽奖设置" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated  @RequestBody TAwardProduct tAwardProduct) {
        return toAjax(tAwardProductService.save(tAwardProduct));
    }

    /**
     * 修改抽奖设置
     */
    //@RequiresPermissions("business:awardproduct:edit")
    @Log(title = "抽奖设置" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TAwardProduct tAwardProduct) {
        return toAjax(tAwardProductService.updateById(tAwardProduct));
    }

    /**
     * 删除抽奖设置
     */
    //@RequiresPermissions("business:awardproduct:remove")
    @Log(title = "抽奖设置" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tAwardProductService.removeByIds(Arrays.asList(ids)));
    }
}
